from flask import Flask 
from jsonrpc.backend.flask import api #json-rpc

app = Flask(__name__)
app.add_url_rule('/api', 'api', api.as_view(), methods=['POST'])

#@api.dispatcher.add_method
#def add(x: int, y: int) -> int:
#    return x + y


class CommonService:
    def tick(self) -> str:
        return "Hello"
    def exit(self) -> bool:
        return True

class MathService:
    def add(self, x: int, y: int) -> int:
        return x + y

api.dispatcher.build_method_map(CommonService())
api.dispatcher.build_method_map(MathService())

app.run(debug=True)
